package it.afs.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.UUID;

public final class Path {
	
	public static String combine(String path1, String path2)
	{
		if(path1.lastIndexOf(File.separator) == path1.length() - 1)
		{
			return path1 + path2;
		}
		else
		{
			return path1 + File.separator + path2;
		}
	}
	
	public static byte[] readFile(String path)
	{
		File pdf = new File(path);
		
		try {
			FileInputStream fis = new FileInputStream(pdf);
			byte[] bytes = new byte[fis.available()];
			fis.read(bytes);
			fis.close();
			
			return bytes;
		} catch (FileNotFoundException e) {
			return null;
		} catch (IOException e) {
			return null;
		}
	}
	
	public static String generateUniqueFilename()
	{
		UUID uuid = UUID.randomUUID();
		return uuid.toString();
	}
	
}
